package com.sfh.gd.service.rule;

import com.sfh.gd.converter.GameConverter;
import com.sfh.gd.domain.dto.GameRuleDTO;
import com.sfh.gd.domain.entity.GameDO;
import com.sfh.gd.domain.entity.GamePKDO;
import com.sfh.gd.domain.entity.GameTeamDO;
import com.sfh.gd.service.rule.impl.PKArrangeA;
import com.sfh.gd.service.rule.impl.PointsComputeA;

import java.util.List;
import java.util.Map;


public interface RuleFactory {

    interface Compute {
        /**
         * 积分晋级赛 - 积分计算规则-弃权
         *
         * @param winTeamId   胜利方ID
         * @param gamePKDO    比赛对象
         */
        GamePKDO computeTeamAbandon(Long winTeamId, GamePKDO gamePKDO);

        /**
         * 积分晋级赛 - 积分计算规则-正常
         *
         * @param winTeamId   胜利方ID
         * @param gamePKDO    比赛对象
         */
        GamePKDO computeTeamNormal(Long winTeamId, GamePKDO gamePKDO);
    }

    interface Pk {
        /**
         * 积分晋级赛 - 比赛结果处理
         *
         */
        List<GamePKDO> pkResult(Map<String, GameTeamDO> waiting);
    }

    static Compute getCompute(GameDO game) {
        String ruleJson = game.getRuleJson();
        if (ruleJson != null) {
            //1 积分晋级赛(默认值) 字符转为对象
            GameRuleDTO gameRuleDTO = GameConverter.INSTANCE.gameRuleJsonToDTO(ruleJson);
            return new PointsComputeA(gameRuleDTO);
        }

        return null;
    }

    static Pk getPk(GameDO game) {

        String ruleJson = game.getRuleJson();
        if (ruleJson != null) {
            //1 积分晋级赛(默认值) 字符转为对象
            GameRuleDTO gameRuleDTO = GameConverter.INSTANCE.gameRuleJsonToDTO(ruleJson);
            return new PKArrangeA();
        }
        return null;
    }
}
